﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:wpfSample="clr-namespace:WPFSample"
                    xmlns:demonstrationShowcases="clr-namespace:WPFSample.DemonstrationShowcases">
    <DataTemplate DataType="{x:Type demonstrationShowcases:DynamicCollectionDependencyVM}">
        <DataTemplate.Resources>
            <wpfSample:CustomBooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"></wpfSample:CustomBooleanToVisibilityConverter>
            <wpfSample:CustomBooleanToVisibilityConverter x:Key="BooleanToVisibilityConverterInverted"
                                                          Inverted="True"></wpfSample:CustomBooleanToVisibilityConverter>
        </DataTemplate.Resources>
        <Viewbox Stretch="Uniform">
            <Grid Background="White"
                  Width="1366"
                  Height="768">
                <Grid.Resources>
                    <Style TargetType="Button">
                        <Style.Setters>
                            <Setter Property="Background"
                                    Value="Black" />
                            <Setter Property="Foreground"
                                    Value="White" />
                        </Style.Setters>
                    </Style>
                    <DataTemplate x:Key="ChildTemplate">
                        <Grid Width="309"
                              Height="100">
                            <Rectangle Fill="White"
                                       HorizontalAlignment="Stretch"
                                       Stroke="Black"
                                       VerticalAlignment="Stretch"
                                       StrokeThickness="3"
                                       RadiusX="5"
                                       RadiusY="5" />
                            <Grid Margin="0,-30,0,0">
                                <Ellipse Fill="#FF509545"
                                         HorizontalAlignment="Left"
                                         Height="73"
                                         Margin="27,43,0,0"
                                         Stroke="Black"
                                         VerticalAlignment="Top"
                                         Width="74" />
                                <Rectangle Fill="#FF0A0101"
                                           HorizontalAlignment="Left"
                                           Height="5.103"
                                           Margin="116.562,77.222,0,0"
                                           Stroke="Black"
                                           VerticalAlignment="Top"
                                           Width="57.052"
                                           RenderTransformOrigin="0.5,0.5"
                                           UseLayoutRounding="False"
                                           >
                                    <Rectangle.RenderTransform>
                                        <RotateTransform Angle="-0.481"
                                                            />
                                    </Rectangle.RenderTransform>
                                </Rectangle>
                                <TextBox HorizontalAlignment="Left"
                                         Margin="31,64,0,0"
                                         TextWrapping="Wrap"
                                         Text="{Binding B1, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                         VerticalAlignment="Top"
                                         Height="33"
                                         Width="65"
                                         TextAlignment="Center"
                                         FontSize="24" />
                                <TextBlock HorizontalAlignment="Left"
                                           Margin="88,103,0,0"
                                           TextWrapping="Wrap"
                                           Text="B1"
                                           VerticalAlignment="Top"
                                           Foreground="#FF170101" />
                                <Ellipse Fill="#FF454595"
                                         HorizontalAlignment="Left"
                                         Height="73"
                                         Margin="211,42,0,0"
                                         Stroke="Black"
                                         VerticalAlignment="Top"
                                         Width="74" />
                                <TextBlock HorizontalAlignment="Left"
                                           Margin="212,65,0,0"
                                           TextWrapping="Wrap"
                                           Text="{Binding A1}"
                                           Foreground="White"
                                           VerticalAlignment="Top"
                                           FontSize="24"
                                           Width="69"
                                           Height="29"
                                           TextAlignment="Center" />
                                <Path Data="M150,250 L200,200 L250,250"
                                      Fill="#FF0A0101"
                                      HorizontalAlignment="Left"
                                      Height="27.831"
                                      Margin="175.895,66.066,0,0"
                                      Stretch="Fill"
                                      Stroke="Black"
                                      UseLayoutRounding="False"
                                      VerticalAlignment="Top"
                                      Width="22.503"
                                      RenderTransformOrigin="0.5,0.5">
                                    <Path.RenderTransform>
                                        <RotateTransform Angle="88.999" />
                                    </Path.RenderTransform>
                                </Path>
                                <TextBlock HorizontalAlignment="Left"
                                           Margin="273,102,0,0"
                                           TextWrapping="Wrap"
                                           Text="A1"
                                           VerticalAlignment="Top"
                                           Foreground="#FF170101" />
                                <TextBlock HorizontalAlignment="Left"
                                           Height="40"
                                           Margin="134,35,0,0"
                                           TextWrapping="Wrap"
                                           Text="x3"
                                           VerticalAlignment="Top"
                                           Width="48"
                                           Foreground="#FF1313DE"
                                           FontSize="32"
                                           FontWeight="Bold" />
                                <Button Margin="5, 35, 0,0"
                                        VerticalAlignment="Top"
                                        HorizontalAlignment="Left"
                                        Content="-"
                                        Width="20"
                                        Height="30"
                                        Command="{Binding RemoveCommand}" />
                            </Grid>
                        </Grid>
                    </DataTemplate>
                </Grid.Resources>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>
                <TextBlock HorizontalAlignment="Left"
                           Margin="60,205,0,0"
                           TextWrapping="Wrap"
                           Text="A:"
                           VerticalAlignment="Top"
                           Foreground="#FF170101"
                           FontSize="48" />
                <TextBlock HorizontalAlignment="Left"
                           Margin="60,355,0,0"
                           TextWrapping="Wrap"
                           Text="B:"
                           VerticalAlignment="Top"
                           Foreground="#FF170101"
                           FontSize="48" />
                <TextBlock HorizontalAlignment="Left"
                           Margin="396,34,0,0"
                           TextWrapping="Wrap"
                           VerticalAlignment="Top"
                           FontSize="24"
                           FontStyle="Italic">
    		<Run Foreground="#FF170101"
                    Text="Dynamic Collection Dependency Demonstration" />
    		<LineBreak />
    		<Run Foreground="#FF170101" />
                </TextBlock>

                <Grid Margin="150,118,50,0">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>
                    <Rectangle Fill="Transparent"
                               Grid.ColumnSpan="3"
                               Stroke="Black"
                               VerticalAlignment="Stretch"
                               HorizontalAlignment="Stretch"
                               StrokeThickness="3"
                               RadiusX="5"
                               RadiusY="5" />
                    <ScrollViewer HorizontalAlignment="Left"
                                  Height="300"
                                  MaxHeight="300"
                                  Grid.Row="0"
                                  Margin="10,80,0,40"
                                  VerticalAlignment="Stretch">
                        <ItemsControl HorizontalAlignment="Left"
                                      Width="309"
                                      ItemsSource="{Binding Destination.Children1}"
                                      Grid.Row="0"
                                      VerticalAlignment="Stretch"
                                      ItemTemplate="{StaticResource ChildTemplate}"
                                      BorderBrush="Black">
                        </ItemsControl>
                    </ScrollViewer>

                    <ScrollViewer HorizontalAlignment="Stretch"
                                  Height="300"
                                  MaxHeight="300"
                                  Grid.Column="2"
                                  Margin="0,80,10,40"
                                  VerticalAlignment="Stretch">
                        <ItemsControl HorizontalAlignment="Left"
                                      Width="309"
                                      ItemsSource="{Binding Destination.Children2}"
                                      Grid.Row="0"
                                      VerticalAlignment="Stretch"
                                      ItemTemplate="{StaticResource ChildTemplate}"
                                      BorderBrush="Black">
                        </ItemsControl>
                    </ScrollViewer>

                    <Rectangle Fill="Black"
                               HorizontalAlignment="Stretch"
                               Height="4"
                               Margin="0,33,0,0"
                               Stroke="Black"
                               StrokeThickness="2"
                               VerticalAlignment="Top"
                               Grid.ColumnSpan="3" />
                    <TextBlock HorizontalAlignment="Center"
                               TextAlignment="Center"
                               Height="30"
                               Margin="0,6,0,0"
                               TextWrapping="Wrap"
                               Foreground="Black"
                               Text="Destination"
                               VerticalAlignment="Top"
                               Grid.ColumnSpan="3"
                               FontSize="21.333" />
                    <Grid Margin="0,42,0,-42"
                          Grid.Column="1">
                        <Grid Margin="-270,10,0,-10">
                            <Ellipse Fill="#FF454595"
                                     HorizontalAlignment="Left"
                                     Height="73"
                                     Margin="512,30,0,0"
                                     Stroke="Black"
                                     VerticalAlignment="Top"
                                     Width="74" />
                            <TextBlock HorizontalAlignment="Left"
                                       Margin="517,53,0,0"
                                       TextWrapping="Wrap"
                                       Text="{Binding Destination.A1}"
                                       Foreground="White"
                                       VerticalAlignment="Top"
                                       FontSize="24"
                                       Width="69"
                                       Height="29"
                                       TextAlignment="Center" />
                            <TextBlock HorizontalAlignment="Left"
                                       Margin="578,90,0,0"
                                       TextWrapping="Wrap"
                                       Text="A1"
                                       VerticalAlignment="Top"
                                       Foreground="#FF170101" />
                            <Ellipse Fill="#FF454595"
                                     HorizontalAlignment="Left"
                                     Height="73"
                                     Margin="512,185,0,0"
                                     Stroke="Black"
                                     VerticalAlignment="Top"
                                     Width="74" />
                            <TextBlock HorizontalAlignment="Left"
                                       Margin="517,208,0,0"
                                       TextWrapping="Wrap"
                                       Text="{Binding Destination.B1}"
                                       Foreground="White"
                                       VerticalAlignment="Top"
                                       FontSize="24"
                                       Width="69"
                                       Height="29"
                                       TextAlignment="Center" />
                            <TextBlock HorizontalAlignment="Left"
                                       Margin="578,245,0,0"
                                       TextWrapping="Wrap"
                                       Text="B1"
                                       VerticalAlignment="Top"
                                       Foreground="#FF170101" />
                            <Rectangle Fill="#FF0A0101"
                                       HorizontalAlignment="Left"
                                       Height="6.431"
                                       Margin="515.958,147.319,0,0"
                                       Stroke="Black"
                                       VerticalAlignment="Top"
                                       Width="65.503"
                                       RenderTransformOrigin="0.5,0.5"
                                       UseLayoutRounding="False"
                                       >
                                <Rectangle.RenderTransform>
                                    <RotateTransform Angle="-269.383"
                                                        />
                                </Rectangle.RenderTransform>
                            </Rectangle>
                            <Path Data="M150,250 L200,200 L250,250"
                                  Fill="#FF0A0101"
                                  HorizontalAlignment="Left"
                                  Height="27.831"
                                  Margin="536.988,107.936,0,0"
                                  Stretch="Fill"
                                  Stroke="Black"
                                  UseLayoutRounding="False"
                                  VerticalAlignment="Top"
                                  Width="22.503"
                                  RenderTransformOrigin="0.5,0.5">
                                <Path.RenderTransform>
                                    <RotateTransform Angle="-2.521" />
                                </Path.RenderTransform>
                            </Path>
                            <TextBlock HorizontalAlignment="Left"
                                       Height="40"
                                       Margin="555,140,0,0"
                                       TextWrapping="Wrap"
                                       Text="+"
                                       VerticalAlignment="Top"
                                       Width="48"
                                       Foreground="#FF1313DE"
                                       FontSize="32"
                                       FontWeight="Bold" />
                            <Grid Margin="360,185,244,185"
                                  x:Name="SumOfAllLeft"
                                  Visibility="{Binding Destination.IsUsingChildren1, Converter={StaticResource BooleanToVisibilityConverter}}">
                                <Rectangle Fill="#FF0A0101"
                                           HorizontalAlignment="Left"
                                           Height="5.425"
                                           Margin="-70.052,33.457,0,0"
                                           Stroke="Black"
                                           VerticalAlignment="Top"
                                           Width="179.555"
                                           RenderTransformOrigin="0.5,0.5"
                                           UseLayoutRounding="False"
                                           >
                                    <Rectangle.RenderTransform>
                                        <RotateTransform Angle="-180.009"
                                                            />
                                    </Rectangle.RenderTransform>
                                </Rectangle>
                                <Path Data="M150,250 L200,200 L250,250"
                                      Fill="#FF0A0101"
                                      HorizontalAlignment="Left"
                                      Height="27.831"
                                      Margin="111.536,21.677,0,0"
                                      Stretch="Fill"
                                      Stroke="Black"
                                      UseLayoutRounding="False"
                                      VerticalAlignment="Top"
                                      Width="22.503"
                                      RenderTransformOrigin="0.5,0.5">
                                    <Path.RenderTransform>
                                        <RotateTransform Angle="89.906" />
                                    </Path.RenderTransform>
                                </Path>
                                <TextBlock HorizontalAlignment="Left"
                                           Height="40"
                                           Margin="-31,0,0,0"
                                           TextWrapping="Wrap"
                                           Text="Sum of all"
                                           VerticalAlignment="Top"
                                           Width="185"
                                           Foreground="#FF1313DE"
                                           FontSize="24"
                                           FontWeight="Bold" />
                            </Grid>
                            <TextBlock HorizontalAlignment="Left"
                                       Margin="0,-4,0,0"
                                       TextWrapping="Wrap"
                                       VerticalAlignment="Top">
    					<Run Foreground="#FF1B1818"
                                FontSize="21.333"
                                Text="Children 1" />
                            </TextBlock>
                            <Grid Margin="605,185,0,185"
                                  x:Name="SumOfAllRight"
                                  Visibility="{Binding Destination.IsUsingChildren1, Converter={StaticResource BooleanToVisibilityConverterInverted}}">
                                <TextBlock HorizontalAlignment="Left"
                                           Height="40"
                                           Margin="35,0,-27,0"
                                           TextWrapping="Wrap"
                                           Text="Sum of all"
                                           VerticalAlignment="Top"
                                           Width="185"
                                           Foreground="#FF1313DE"
                                           FontSize="24"
                                           FontWeight="Bold" />
                                <Rectangle Fill="#FF0A0101"
                                           HorizontalAlignment="Left"
                                           Height="5.425"
                                           Margin="17.267,33.229,0,0"
                                           Stroke="Black"
                                           VerticalAlignment="Top"
                                           Width="132.1"
                                           RenderTransformOrigin="0.5,0.5"
                                           UseLayoutRounding="False"
                                           >
                                    <Rectangle.RenderTransform>
                                        <RotateTransform Angle="-180.009"
                                                            />
                                    </Rectangle.RenderTransform>
                                </Rectangle>
                                <Path Data="M150,250 L200,200 L250,250"
                                      Fill="#FF0A0101"
                                      HorizontalAlignment="Left"
                                      Height="27.831"
                                      Margin="0,22.585,0,0"
                                      Stretch="Fill"
                                      Stroke="Black"
                                      UseLayoutRounding="False"
                                      VerticalAlignment="Top"
                                      Width="22.503"
                                      RenderTransformOrigin="0.5,0.5">
                                    <Path.RenderTransform>
                                        <RotateTransform Angle="-88.793" />
                                    </Path.RenderTransform>
                                </Path>
                            </Grid>
                            <TextBlock HorizontalAlignment="Left"
                                       Margin="790,-4,-130,0"
                                       TextWrapping="Wrap"
                                       VerticalAlignment="Top"
                                       Width="101">
    					<Run Foreground="#FF1B1818"
                                FontSize="21.333"
                                Text="Children 2" />
                            </TextBlock>
                            <Button Content="Click here to use Children 1"
                                    Background="DarkRed"
                                    Visibility="{Binding Destination.IsUsingChildren1, Converter={StaticResource BooleanToVisibilityConverterInverted}}"
                                    Command="{Binding Destination.UseLeftCommand}"
                                    HorizontalAlignment="Left"
                                    Margin="280,235,0,0"
                                    FontSize="10.667"
                                    VerticalAlignment="Top"
                                    Width="215"
                                    Height="30" />
                            <Button Content="Click here to use Children 2"
                                    Background="DarkRed"
                                    Visibility="{Binding Destination.IsUsingChildren1, Converter={StaticResource BooleanToVisibilityConverter}}"
                                    Command="{Binding Destination.UseRightCommand}"
                                    HorizontalAlignment="Left"
                                    Margin="595,235,0,0"
                                    VerticalAlignment="Top"
                                    Width="166"
                                    Height="30"
                                    FontSize="10.667" />
                        </Grid>
                    </Grid>
                    <Button Content="Add"
                            Command="{Binding Destination.AddToChildren1Command}"
                            HorizontalAlignment="Left"
                            Margin="184,42,0,0"
                            Width="80"
                            Height="30"
                            VerticalAlignment="Top" />
                    <Button Content="Add"
                            Command="{Binding Destination.AddToChildren2Command}"
                            HorizontalAlignment="Left"
                            Margin="167,42,0,0"
                            Width="80"
                            Height="30"
                            VerticalAlignment="Top"
                            Grid.Column="2" />
                </Grid>

                <Grid Margin="60,20,0,0"
                      x:Name="Legend"
                      Grid.Row="1">
                    <TextBlock HorizontalAlignment="Left"
                               Margin="2,0,0,0"
                               TextWrapping="Wrap"
                               VerticalAlignment="Top">
    			<Run Foreground="#FF1B1818"
                        FontSize="21.333"
                        Text="Legend:" />
                    </TextBlock>
                    <Ellipse Fill="#FF454595"
                             HorizontalAlignment="Left"
                             Height="35"
                             Margin="2,62,0,0"
                             Stroke="Black"
                             VerticalAlignment="Top"
                             Width="35" />
                    <TextBlock HorizontalAlignment="Left"
                               Margin="128,70,0,0"
                               TextWrapping="Wrap"
                               VerticalAlignment="Top"
                               Foreground="#FF0A0101"
                               Height="22"
                               FontSize="16">
    			<Run Text="Evaluated Property (Read Only)" />
    			<LineBreak />
    			<LineBreak />
    			<Run />
                    </TextBlock>
                    <Ellipse Fill="#FF509545"
                             HorizontalAlignment="Left"
                             Height="33"
                             Margin="2,102,0,0"
                             Stroke="Black"
                             VerticalAlignment="Top"
                             Width="35" />
                    <TextBlock HorizontalAlignment="Left"
                               Margin="128,107,0,0"
                               TextWrapping="Wrap"
                               VerticalAlignment="Top"
                               Foreground="#FF0A0101"
                               Height="22"
                               FontSize="16"
                               Text="Input Property" />
                    <TextBlock HorizontalAlignment="Left"
                               Height="40"
                               Margin="8,22,0,0"
                               TextWrapping="Wrap"
                               Text="+ - / x"
                               VerticalAlignment="Top"
                               Width="102"
                               Foreground="#FF1313DE"
                               FontSize="32"
                               FontWeight="Bold" />
                    <TextBlock HorizontalAlignment="Left"
                               Margin="31,89,0,0"
                               TextWrapping="Wrap"
                               Text="Name"
                               VerticalAlignment="Top"
                               Foreground="#FF170101"
                               RenderTransformOrigin="-32.691,-18.534"
                               FontSize="9.333" />
                    <TextBlock HorizontalAlignment="Left"
                               Margin="31,129,0,0"
                               TextWrapping="Wrap"
                               Text="Name"
                               VerticalAlignment="Top"
                               Foreground="#FF170101"
                               RenderTransformOrigin="-32.691,-18.534"
                               FontSize="9.333" />
                    <TextBlock HorizontalAlignment="Left"
                               Margin="128,33,0,0"
                               TextWrapping="Wrap"
                               VerticalAlignment="Top"
                               Foreground="#FF0A0101"
                               Height="22"
                               FontSize="16"
                               Text="Math operation applied to the source property's value before it is added to the sink property" />

                    <Rectangle Fill="White"
                               HorizontalAlignment="Left"
                               Height="48"
                               Margin="0,154,0,0"
                               Stroke="Black"
                               VerticalAlignment="Top"
                               Width="110"
                               StrokeThickness="3"
                               RadiusX="5"
                               RadiusY="5" />
                    <Rectangle Fill="Black"
                               HorizontalAlignment="Left"
                               Height="4"
                               Margin="2,173,0,0"
                               Stroke="Black"
                               StrokeThickness="2"
                               VerticalAlignment="Top"
                               Width="108" />
                    <TextBlock HorizontalAlignment="Left"
                               Margin="128,155,0,0"
                               TextWrapping="Wrap"
                               VerticalAlignment="Top"
                               Foreground="#FF0A0101"
                               Height="22"
                               FontSize="16"
                               Text="Entity, represented by an instance of a class" />
                </Grid>
            </Grid>
        </Viewbox>
    </DataTemplate>
</ResourceDictionary>